package FileHandling;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import EventHandling.AbstractEventHandler;

public class FileHandler {

	static BufferedReader br;
	String tswLog;
	public static int lineCount;


	public FileHandler() {
		this.lineCount = 0;	
	}

	public void readFileByLine() throws IOException {
		//this method passes each line to the abstractEventHandler which processes it by type

		br = new BufferedReader(new FileReader(tswLog));
		try {
			String test;
			while ((test = br.readLine()) != null) {
				AbstractEventHandler.handle(test);
			}
		}catch(IOException e) {
			System.out.println("File issues");
		}finally {
			try {
				if (br != null)br.close();
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		}
	}

	public void setTswLog(String tswLog) {
		this.tswLog = tswLog;
	}
}
